<?php

namespace Drupal\shusy_cash\ViewsController;

use Drupal\shusy_cash\ViewsController\handler\field\ShusyCashAmountViewsField;
use Drupal\shusy_cash\ViewsController\handler\field\ShusyCashEditLinkViewsField;
use Drupal\shusy_cash\ViewsController\handler\field\ShusyCashHandlerViewsField;
use Drupal\shusy_cash\ViewsController\handler\field\ShusyCashStatusViewsField;
use Drupal\shusy_cash\ViewsController\handler\field\ShusyCashTypeViewsField;
use Drupal\shusy_cash\ViewsController\handler\filter\ShusyCashHandlerViewsFilter;
use Drupal\shusy_cash\ViewsController\handler\filter\ShusyCashStatusViewsFilter;
use Drupal\shusy_cash\ViewsController\handler\filter\ShusyCashTypeViewsFilter;
use EntityDefaultViewsController;


class ShusyCashViewsController extends EntityDefaultViewsController {

  public function views_data() {
    $data = parent::views_data();
    if (!empty($this->info['base table'])) {
      $table = $this->info['base table'];
      $revision_table = $this->info['revision table'];
      $info = [];

      $info[$table]['edit_link'] = [
        'title' => t('编辑'),
        'help' => t('编辑.'),
        'field' => [
          'handler' => ShusyCashEditLinkViewsField::class,
        ],
      ];
      $info[$table]['type'] = [
        'title' => '提现类型',
        'help' => '提现类型',
        'real field' => 'type',
        'field' => [
          'handler' => ShusyCashTypeViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyCashTypeViewsFilter::class,
        ],
      ];
      $info[$table]['amount'] = [
        'title' => '提现金额',
        'help' => '提现金额',
        'real field' => 'amount',
        'field' => [
          'handler' => ShusyCashAmountViewsField::class,
        ],
      ];
      $info[$table]['status'] = [
        'title' => '状态 0 待审核 1 通过 2 不通过 3 处理中 4 处理完成 5 处理失败',
        'help' => '状态 0 待审核 1 通过 2 不通过 3 处理中 4 处理完成 5 处理失败',
        'real field' => 'status',
        'field' => [
          'handler' => ShusyCashStatusViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyCashStatusViewsFilter::class,
        ],
      ];
      $info[$table]['handler'] = [
        'title' => '提现处理',
        'help' => '提现处理',
        'real field' => 'handler',
        'field' => [
          'handler' => ShusyCashHandlerViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyCashHandlerViewsFilter::class,
        ],
      ];
      $info[$table]['apply_amount'] = [
        'title' => '申请提现金额',
        'help' => '申请提现金额',
        'real field' => 'apply_amount',
        'field' => [
          'handler' => \Drupal\shusy_cash\ViewsController\handler\field\ShusyCashApplyAmountViewsField::class,
        ],
      ];
      $info[$table]['service_amount'] = [
        'title' => '手续费',
        'help' => '手续费',
        'real field' => 'service_amount',
        'field' => [
          'handler' => \Drupal\shusy_cash\ViewsController\handler\field\ShusyCashServiceAmountViewsField::class,
        ],
      ];
      $info[$revision_table]['apply_amount'] = [
        'title' => '申请提现金额',
        'help' => '申请提现金额',
        'real field' => 'apply_amount',
        'field' => [
          'handler' => \Drupal\shusy_cash\ViewsController\handler\field\ShusyCashApplyAmountViewsField::class,
        ],
      ];
      $info[$revision_table]['service_amount'] = [
        'title' => '手续费',
        'help' => '手续费',
        'real field' => 'service_amount',
        'field' => [
          'handler' => \Drupal\shusy_cash\ViewsController\handler\field\ShusyCashServiceAmountViewsField::class,
        ],
      ];
      $data = drupal_array_merge_deep($data, $info);
    }
    return $data;
  }

}
